package com.he.controller;

import com.dingtalk.api.request.OapiChatSendRequest;
import com.he.pojo.Dept;
import com.he.pojo.ServiceResult;
import com.he.pojo.User;
import com.he.services.impl.DeptServiceImpl;
import com.he.services.impl.UserServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: usersync
 * @description:
 * @author: xin.he
 * @create: 2021-06-06 12:32
 **/

@RestController
@RequestMapping("/dept")
public class DeptController {
    private static final Logger log = LoggerFactory.getLogger(DeptController.class);

    @Autowired
    DeptServiceImpl deptService;

    @GetMapping("/queryAll")
    public List<Dept> queryAll (){
        return deptService.queryAll();
    }

    @GetMapping("/syncDept")
    public ServiceResult<String> syncDept(){

        try {
           String msg = deptService.saveDingDeptList();
            log.info(msg);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ServiceResult.failure("400",e.getMessage());
        }
        return ServiceResult.success("正在同步,请稍后...");
    }

    @GetMapping("/getDidList")
    public void getDidList(){
        List<String> idLIst = deptService.getDeptIdLIst();
        log.info(idLIst.toString());
    }

}
